package com.qa.dom.service.impl;

import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.qa.dom.dto.MyMessageDto;
import com.qa.dom.entity.Usertable;
import com.qa.dom.mapper.QuestionanswerMapper;
import com.qa.dom.entity.Questionanswer;
import com.qa.dom.service.IQuestionanswerService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 答疑记录表 服务实现类
 * </p>
 *
 * @author cxj
 * @since 2018-04-24
 */
@Service
public class QuestionanswerServiceImpl extends ServiceImpl<QuestionanswerMapper, Questionanswer> implements IQuestionanswerService {

    @Resource
    QuestionanswerMapper mapper;

    @Override
    public Page queryMyMessage(Page page, Usertable usertable) {
        //如果是老师,调用老师的消息页面，展示的是跟他对过话的学生
        List<MyMessageDto> list = mapper.queryTeacherSelfMessage(page,usertable);
        /*
        如果是学生的消息页面，展示跟他对过话的老师//判断如果该用户的教师课程为null,
        则该用户是学生
        if(StringUtils.isEmpty(usertable.getTeacherGrade())){
            list = mapper.queryStudentSelfMessage(page,usertable);
        }*/

        page.setRecords(list);
        page.setTotal(list.size());
        return page;
    }
}
